#pragma once
#include "..\Core\BasicTypes\BaseTypes.h"
#include <vector>
#include <memory>
#include <list>
namespace re
{
	namespace io
	{
		//-------------------------------------------------------------------------------------------------//
		//-------------------------------------------------------------------------------------------------//
		//Raw Resource Loading(from the HD)
		//-------------------------------------------------------------------------------------------------//
		//-------------------------------------------------------------------------------------------------//


		//-------------------------------------------------------------------------------------------------
		//Resourc Handle Interface
		//-------------------------------------------------------------------------------------------------
		class IResourceHandle;
		typedef std::tr1::shared_ptr<IResourceHandle> ResourceHandlePtr;
		class IResourceHandle
		{
		public:
			IResourceHandle() {}
			~IResourceHandle() {}

			virtual const S8* GetData() = 0;
			virtual const U32 GetSize() = 0;

		};
		//-------------------------------------------------------------------------------------------------
		//Resource Unpacker/Extracter
		//-------------------------------------------------------------------------------------------------
		class IResourceUnpacker;
		typedef std::tr1::shared_ptr<IResourceUnpacker> ResourceUnpackerPtr;
		class IResourceUnpacker
		{
		public:
			IResourceUnpacker() {}
			~IResourceUnpacker() {}

			virtual U32 LoadFile(const std::wstring & filename, const std::wstring * virtualfn, S8 ** buffer) = 0;
			virtual bool FileExist(const std::wstring & realfile, const std::wstring * virtualfn) = 0;
		};
		//-------------------------------------------------------------------------------------------------
		//Resource Cache 
		//-------------------------------------------------------------------------------------------------
		class IResourceCache;
		typedef std::tr1::shared_ptr<IResourceCache> ResourceCachePtr;
		class IResourceCache
		{
		public:
			IResourceCache() {}
			~IResourceCache() {}
			
			virtual ResourceHandlePtr GetResource(const std::wstring & filename) = 0; // is loaded? -> return, !-> load and return
			
			virtual bool AddResourceUnpacker(std::wstring & format, ResourceUnpackerPtr loader) = 0;
			virtual bool RemoveResourceUnpacker(ResourceUnpackerPtr loader) = 0;

			virtual bool ReleaseCache() = 0;
		
		};


		//-------------------------------------------------------------------------------------------------//
		//-------------------------------------------------------------------------------------------------//
		//Raw resource handling(turning into something useful)
		//-------------------------------------------------------------------------------------------------//
		//-------------------------------------------------------------------------------------------------//


		//-------------------------------------------------------------------------------------------------
		//AssetData Interface
		//-------------------------------------------------------------------------------------------------
		class IAssetData;
		typedef std::tr1::shared_ptr<IAssetData> AssetDataPtr;
		typedef U32 AssetType;
		typedef std::list<AssetDataPtr> AssetDataList;
		class IAssetData
		{
		public:
			IAssetData() {}
			~IAssetData() {}

			virtual AssetType GetAssetType() = 0;
			virtual AssetDataList& GetChildren() = 0;
		};

		//-------------------------------------------------------------------------------------------------
		//AssetParser
		//-------------------------------------------------------------------------------------------------
		class IAssetParser
		{
		public:
			IAssetParser() {}
			~IAssetParser() {}

			virtual AssetDataList GetAssetDataList(ResourceHandlePtr ptr);
		};

		//-------------------------------------------------------------------------------------------------
		//AssetManager Interface
		//-------------------------------------------------------------------------------------------------
		class IAssetManager
		{
		public:
			IAssetManager() {}
			~IAssetManager() {}

			virtual AssetDataList GetAssetDataList(ResourceHandlePtr handle) = 0;
			virtual AssetDataList GetAssetDataList(ResourceHandlePtr handle, const std::wstring & name) = 0;
		};


	}
}